package com.sky.mapper;


import com.github.pagehelper.Page;
import com.sky.entity.Orders;
import com.sky.vo.OrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {




    void insert(Orders orders);



    /**
     * 根据订单号和用户id查询订单
     * @param orderNumber
     * @param userId
     */
    @Select("select * from orders where number = #{orderNumber} and user_id= #{userId}")
    Orders getByNumberAndUserId(String orderNumber, Long userId);

    /**
     * 修改订单信息
     * @param orders
     */
    void update(Orders orders);


    Page<Orders> getOrederByUserStatus(Map map);

    //--根据唯一id查订单
    @Select("select * from orders where id= #{id}")
    Orders getOneById(Long id);

    //--T3--各个状态的订单数量统计
    @Select("select count(*) from orders where status=#{statusNum}")
    Integer getOrderStatistics(Integer statusNum);


    //--P1--定时--根据状态和下单时间查询订单
    @Select("select * from orders where status = #{status} and order_time < #{orderTime}")
    List<Orders> getByStatusAndOrdertimeLT(Integer status, LocalDateTime orderTime);

    //查询当天总金额
    Double sumByMap(Map param);

    //查询订单数量
    Integer countByMap(Map param);

    List<Map> selectSumCopiesAndLimit(LocalDate begin, LocalDate end);
}
